//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "CDBListb.h"
#pragma package(smart_init)
#include <eic.h>

//---------------------------------------------------------------------------
#define COL_DISABLE  clBtnFace
//---------------------------------------------------------------------------
// ValidCtrCheck est utilisé pour être sûr que les composants créés ne
// contiennent aucune fonction virtuelle pure.
//

static inline void ValidCtrCheck(CDBListBox *)
{
    new CDBListBox(NULL);
}
//---------------------------------------------------------------------------
__fastcall CDBListBox::CDBListBox(TComponent* Owner)
    : TDBListBox(Owner)
{
  m_Enabled                    = true;
  m_ReadOnly                   = false;
  m_pfnOnEstCorrectementRempli = NULL;
  m_OldWndProc_Parent          = NULL;
  m_OldParent                  = NULL;
}
__fastcall CDBListBox::~CDBListBox()
{
  if( m_OldParent && m_OldWndProc_Parent)
    m_OldParent->WindowProc = m_OldWndProc_Parent;
}
//---------------------------------------------------------------------------
void __fastcall CDBListBox::SetEnabled(bool value)
{
  m_Enabled = value;
  TDBListBox::Enabled = m_Enabled;
  RafraichirFond(this);
}
//---------------------------------------------------------------------------
void __fastcall CDBListBox::SetReadOnly(bool value)
{
  m_ReadOnly = value;
  TDBListBox::ReadOnly = m_ReadOnly;
  RafraichirFond(this);
}
//---------------------------------------------------------------------------
bool __fastcall CDBListBox::EstCorrectementRempliDefault( void)
{
  return( ItemIndex != -1);
}
void __fastcall CDBListBox::SetObligatoire(bool value)
{
  m_Obligatoire = value;
  RafraichirFond(this);
}
//---------------------------------------------------------------------------
void __fastcall CDBListBox::SetParent(TWinControl* AParent)
{
    if( m_OldWndProc_Parent)
    {
      m_OldParent->WindowProc = m_OldWndProc_Parent;
      m_OldWndProc_Parent = NULL;
      m_OldParent = NULL;
    }
    inherited::SetParent( AParent);
    if( AParent)
    {
      m_OldWndProc_Parent   = AParent->WindowProc;
      m_OldParent = AParent;
      AParent->WindowProc = WndProc_Parent;
    }
}
//---------------------------------------------------------------------------
void __fastcall CDBListBox::WndProc_Parent( TMessage &Message )
{
  m_OldWndProc_Parent( Message );
	if( (Message.Msg == WM_COMMAND) && ( Message.WParamHi == LBN_SELCHANGE) )
    RafraichirFond(this);
}
//---------------------------------------------------------------------------
namespace Cdblistb
{
    void __fastcall PACKAGE Register()
    {
        TComponentClass classes[1] = {__classid(CDBListBox)};
        RegisterComponents("EIC CtrlDB", classes, 0);
    }
}
//---------------------------------------------------------------------------
void __fastcall CDBListBox::SetBleuSiHint(bool value)
{
  m_BleuSiHint = value;
  RafraichirFond(this);
}
//---------------------------------------------------------------------------